﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartSpace.Core
{
    public interface ICoreService
    {
        User GetUser(string account);
        User GetUser(Guid id);
        List<User> GetUsers(List<Guid> idList);

        #region role
        PagedList<Role> GetRoles(int start, int limit);
        PagedList<User> GetUsers(int start, int limit);
        PagedList<User> FindUsers(string filter, int start, int limit);
        Role GetRole(Guid roleId);

        bool AssignRoleToUser(Role role, User user);
        bool RemoveRoleFromUser(User user);
        bool RemoveRoleFromUser(Guid userId);

        bool SaveRole(Role role);
        bool DeleteRole(Role role);
        bool DeleteRole(Guid roleId);

        PagedList<User> GetRoleUsers(Guid roleId, int start, int limit);
        #endregion

        bool SaveUser(User user);
        bool DeleteUser(User user);
        bool DeleteUser(Guid userId);

        bool SaveModule(Module module);
        PagedList<Module> GetModules(int start, int limit);
        PagedList<Module> GetModules(string type, int start, int limit);
        Module GetModule(Guid moduleId);
        ModuleView GetView(Guid viewId);

        #region navigation
        bool SaveNavigation(Navigation navigation);
        Navigation GetNavigation(Guid id);
        bool SetDefaultNavigation(Guid id);
        List<Navigation> GetNavigations(Guid applicationId);
        Navigation GetDefaultNavigation(Guid applicationId);
        bool AddRoleNavigation(Guid navigationId, Guid roleId);
        bool DeleteRoleNavigation(Guid navigationId, Guid roleId);
        /// <summary>
        /// 批量设置角色的导航
        /// </summary>
        /// <param name="navigationIds"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        bool SetRoleNavigations(List<Guid> navigationIds, Guid roleId);
        List<Navigation> GetNavigations(Guid applicationId, Guid roleId);
        List<Navigation> GetUserNavigations(Guid applicationId, Guid id);
        List<Navigation> GetUserNavigations(Guid applicationId, string account);
        #endregion

        #region shortcut
        bool AddShortcut(Guid navigationId, string caption);
        bool DeleteShortcut(Guid navigationId);
        List<Shortcut> GetShortcuts(Guid applicationId);
        List<Shortcut> GetShortcuts(Guid applicationId, Guid roleId);
        List<Shortcut> GetUserShortcuts(Guid applicationId, Guid id);
        List<Shortcut> GetUserShortcuts(Guid applicationId, string account);
        #endregion

        #region application
        bool SaveApplication(Application app);
        Application GetApplication(Guid id);
        List<Application> GetApplications();
        List<Application> GetPersonalApplications(string account);
        Application GetPersonalDefaultApplication(string account);
        List<Application> GetApplications(string type);
        List<Application> GetPersonalApplications(string type, string account);
        Application GetPersonalDefaultApplication(string type, string account);
        bool AddModule(Guid applicationId, Guid moduleId);
        bool RemoveModule(Guid applicationId, Guid moduleId);
        List<Module> GetModules(Guid applicationId);
        bool DeleteApplication(Guid applicationId);
        #endregion

        #region Theme
        bool SaveTheme(Theme theme);
        List<Theme> GetThemes();
        List<Theme> GetThemes(string type);
        Theme GetTheme(Guid themeId);
        #endregion

        #region Image
        bool SaveImage(ImageFile image);
        bool DeleteImage(Guid imageId);
        ImageFile GetImage(Guid imageId);
        List<ImageFile> GetImages();
        #endregion

        #region privilege
        bool SavePrivilege(Privilege privilege);
        bool DeletePrivilege(Guid id);
        Privilege GetPrivilege(Guid id);
        PagedList<Privilege> GetPrivileges(string type, int start, int limit);
        PagedList<Privilege> FindPrivileges(string code, int start, int limit);
        #endregion

        #region usergroup
        bool SaveUserGroup(UserGroup group);
        bool DeleteUserGroup(UserGroup group);
        bool AssignUserToUserGroup(Guid userId, Guid groupId);
        PagedList<User> GetUserGroupContainUsers(Guid id, int start, int limit);
        UserGroup GetUserGroup(Guid groupId);
        List<UserGroup> GetUserGroups();
        #endregion

        #region page
        bool SavePage(DynamicPage page);
        DynamicPage GetPage(Guid id);
        DynamicPage GetPage(string name);
        PagedList<DynamicPage> GetPages(int start, int limit);
        DynamicPagePersonalization GetPagePersonalization(Guid pageId);
        DynamicPagePersonalization GetPagePersonalization(string name);
        bool SavePagePersonalization(DynamicPagePersonalization personalization);
        bool SavePageTemplate(PageTemplate template);
        bool DeleteTemplate(string name);
        PageTemplate GetPageTemplate(string name);
        PagedList<PageTemplate> GetPageTemplates(int start, int limit);
        #endregion
    }
}
